<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="show">
        dfafdsafda
    </div>

    <input type="text" class="myinput"><button>点击</button>

    <script>
        // xss攻击；
        // var btn = document.querySelector("button");
        // var myinputEle = document.querySelector(".myinput");
        // var showEle = document.querySelector(".show");
        // btn.onclick = function(){
        //     var val = myinputEle.value;
        //     var reg = /</g;
        //     val = val.replace(reg,"lt;");
        //     var reg = />/g;
        //     val  = val.replace(reg,"gt;")
        //     console.log(val);
        //     var divEle = document.createElement("div");
        //     divEle.innerHTML = val;
        //     showEle.appendChild(divEle);
        // }

        // textContent 可以获取节点里的内容 也可以设置节点里的内容
        var showEle = document.querySelector(".show")
        // console.log(showEle.textContent);
        var nodes = showEle.childNodes[0];
        // console.log(nodes);
        // console.log(nodes.textContent);
        nodes.textContent = "11111";
    </script>
</body>
</html>